package com.wondedDream.controller.admin;

import com.wondedDream.model.UserPracticeRecord;
import com.wondedDream.service.UserPracticeRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController(value = "adminUserPracticeRecordController")
@RequestMapping("/api/userPracticeRecords")
@Api(description = "管理端-用户练习信息")
public class UserPracticeRecordController {

    @Autowired
    private UserPracticeRecordService userPracticeRecordService;


    // 获取用户练习记录信息
    @GetMapping("/{id}")
    @ApiOperation(value = "获取用户练习记录信息")
    public UserPracticeRecord getUserPracticeRecordById(@PathVariable Integer id) {
        return userPracticeRecordService.getUserPracticeRecordById(id);
    }

    // 获取用户的所有练习记录
    @GetMapping("/byUser/{userId}")
    @ApiOperation(value = "获取用户的所有练习记录")
    public List<UserPracticeRecord> getUserPracticeRecordsByUserId(@PathVariable Integer userId) {
        return userPracticeRecordService.getUserPracticeRecordsByUserId(userId);
    }

    // 获取某一练习问题的所有用户练习记录
    @GetMapping("/byPracticeQuestion/{practiceQuestionId}")
    @ApiOperation(value = "获取某一练习问题的所有用户练习记录")
    public List<UserPracticeRecord> getUserPracticeRecordsByPracticeQuestionId(@PathVariable Integer practiceQuestionId) {
        return userPracticeRecordService.getUserPracticeRecordsByPracticeQuestionId(practiceQuestionId);
    }
}